#pragma once
#include <string>
#include <vector>
#include "Result.h"

class Course
{
protected:
	string name;
	int year;
	vector<Result> results;
public:

	Course(void)
	{
		this->name = "";
		this->year = 0;
	}

	Course( string name, int year )
	{
		this->name = name;
		this->year = year;
	}

	~Course(void)
	{
	}

	void AddResult(  )
	{
		Result result;

		cout << "Add result on following form:" << endl;
		cout << "(maxPoint,point,maxGradeThreshold,mediumGradeThreshold,passGradeThreshold)" << endl;
		cin >> result;

		results.push_back( result );
	}

	void LoadResult( Result& result )
	{
		results.push_back( result );
	}

	void SaveResults( ofstream& fout )
	{
		for( auto  &r : results )
		{
			fout << r;
		}
	}

	friend ostream& operator<<( ostream& out, Course& course)
	{
		out << "(name,year) = ";
		out << "(";
		out << course.name << ",";
		out << course.year << ")" << endl;
		return out;
	}

	friend istream& operator>>( istream& in, Course& course)
	{
		char dummyChar;
		in >> dummyChar; // Skip '('
		getline(in, course.name, ',');
		in >> course.year;

		return in;
	}

#pragma region Getters
	string GetName() { return this->name; }
	int GetYear() { return this->year; }  
#pragma endregion


#pragma region Setters
	void SetName( string name ) { this->name = name; }
	void Setyear( int year ) { this->year = year; }  
#pragma endregion

};

